
//关闭购物车弹出层
function closeShoppingCartTip(){
    $("#shoppingCartTip").hide();
    $("#wrap_id").hide();
    $("#wrap_success").hide();
}
//关闭购物车弹出层

//删除收藏商品 start
function deleteSingCollection(skuId){
    var $Arr = new Array();
    $Arr[0] = skuId;
    reomveCollection($Arr);
}
function reomveCollection($Arr){
    $.ajaxSettings['contentType'] = "application/x-www-form-urlencoded; charset=utf-8";
    $.ajax({
                type:"POST",url:dataValue.webRoot+"/member/delUserProductCollect.json",
                data:{items:$Arr.join(",")},
                dataType:"json",
                success:function(data){
                    if (data.success == "true") {
                        memberShowCallBack("删除成功!",function(){window.location.reload()});
                    }else{
                        memberShowTip("系统错误,请刷新重新操作!");
                    }
                }
            });
}
//删除收藏商品 end

/*添加到购物车*/
function addCart(number){
    alert(number);
    var addcart = $(".addcart" + number);
    var addbtn = addcart;
    var skuId = addcart.attr("skuid");
    var num = addcart.attr("num");
    var carttype = addcart.attr("carttype");
    var handler = addcart.attr("handler");

    if(skuId==""){
        memberShowTip("请选择商品规格")
        return;
    }
    $.ajax({
        url:paramData.webRoot+"/cart/add.json",
        data:{type:carttype,objectId:skuId,quantity:num,handler:handler},
        dataType: "json",
        success:function(data) {
            var shoppingcart=data.shoppingCartVo;
            var cartNum=0;
            for(var i=0;i<shoppingcart.items.length;i++){
                cartNum=cartNum+shoppingcart.items[i].quantity;
            }

            var cartLayer=$(".addTobuyCarLayer");
            cartLayer.find(".cartnum").html(cartNum);
            $("#top_myCart_cartNum").html(cartNum);
            cartLayer.find(".cartprice").html(shoppingcart.productDiscountAmount);
            $("#top_myCart_cartNum2").html(cartNum);
            $("#cartTotalPrice").html(shoppingcart.productDiscountAmount);
            $(".addTobuyCarLayer").show().css({
                "top":addbtn.offset().top+"px",
                "margin-left":"35%"

            })
        },
        error:function(XMLHttpRequest, textStatus) {
            if (XMLHttpRequest.status == 500) {
                var result = eval("(" + XMLHttpRequest.responseText + ")");
                memberShowTip(result.errorObject.errorText);
            }
        }
    });
}

